package com.modle;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.ocean.util.common.StringUtil;
import com.common.method.ServerPath;
import com.google.android.imageloader.ImageLoader;
import com.matang.R;
import com.util.OUtil;

public class CFriendContent implements IFriend {

	public User user;
	
	public CFriendContent(User data) {
		super();
		
		this.user = data;
	}

	@Override
	public int getLayout() {
		return R.layout.list_item_contract_content;
	}

	@Override
	public boolean isClickable() {
		return true;
	}

	@Override
	public View getView(Context context, View convertView,
			LayoutInflater inflater) {
		convertView = inflater.inflate(getLayout(), null);
		ImageView iv = (ImageView) convertView.findViewById(R.id.thumb_iv);
		ImageView bgIv = (ImageView) convertView.findViewById(R.id.bg_iv);
		ImageLoader.get(context).bind(iv, ServerPath.SERVER + user.thumb, null,
				R.drawable.default_head);
		
//		bitmapUtils.display(iv, ServerPath.SERVER + user.thumb, new BitmapLoadCallBack<View>() {
//
//		
//			public void onLoadCompleted(View container, String uri,
//					Bitmap bitmap, BitmapDisplayConfig config,
//					BitmapLoadFrom from) {
//				((ImageView)(container)).setImageBitmap(bitmap);
//				
//			}
//
//			@Override
//			public void onLoadFailed(View container, String uri,
//					Drawable drawable) {
//			
//				((ImageView)(container)).setImageResource(R.drawable.default_head);
//			}
//		});
		TextView nameTv = (TextView) convertView.findViewById(R.id.name_tv);
		TextView qmTv = (TextView) convertView.findViewById(R.id.qm_tv);
		
	   if(StringUtil.isNull(user.name)){
			
		 nameTv.setText(StringUtil.mobileEncry(user.mobile));
		}else{
			
			nameTv.setText(user.name);
		}
		qmTv.setText(user.signature+"");
		OUtil.setThumbBg(user, bgIv);

		return convertView;
	}
}
